package com.mofum.scope.entity;

import com.github.pagehelper.PageRowBounds;

/**
 * 分页配置项
 *
 * @Author developer@omuao.com
 * @Time 2018/8/17 0017 13:17
 */
public class Page extends PageRowBounds {

    public static final Page PAGE_DEFAULT = new Page(1,0);

    public static final Page PAGE_ONE = new Page(1,1);

    /**
     * 偏移量
     */
    private int offset;

    /**
     * 数量
     */
    private int limit;


    public Page(int offset, int limit) {
        super(offset, limit);
        this.offset = offset;
        this.limit = limit;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public String getTotals() {
        return String.valueOf(this.getTotal());
    }

    public String getTotalPages() {

        if (limit == 0) {
            limit = 10;
        }

        long count = this.getTotal() / this.limit;

        long mode = this.getTotal() % this.limit;

        count = mode > 0 ? ++count : count;

        return String.valueOf(count) ;
    }


}